import requests

def get_ip_address():
    url = "https://base.dahood.tech/platform/novelship/lists?cursor=0&limit=100"
    payload = {}
    headers = {
        'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
        'x-internal-access': 'mI7lfclmb8tyCDhMgc1gTz6wZVKEQ82f',
        'Accept': '*/*',
        'Host': 'base.dahood.tech',
        'Connection': 'keep-alive'
    }

    response = requests.request("GET", url, headers=headers, data=payload)
    if response.status_code != 200:
        raise Exception(f"请求失败，状态码: {response.status_code}")

    response_json = response.json()
    next = response_json['page']['has_next_page']
    li = response_json['results']
    s = len(li)

    while next:
        cursor = response_json['page']['next_cursor_id']
        url = f"https://base.dahood.tech/platform/novelship/lists?cursor={cursor}&limit=100"
        response = requests.request("GET", url, headers=headers, data=payload)
        if response.status_code != 200:
            raise Exception(f"请求失败，状态码: {response.status_code}")

        response_json = response.json()
        next = response_json['page']['has_next_page']
        li.extend(response_json['results'])
        s += len(response_json['results'])

    return li

# 示例调用
if __name__ == "__main__":
    try:
        results = get_ip_address()
        print(f"获取到的总结果数: {len(results)}")
        # 打印前几个结果以验证
        print(results[:5])
    except Exception as e:
        print(f"错误: {e}")
